//***************************************************************************
//*
//*	File:			DialogFolder.cpp
//*	Description:	Folder dialog
//*
//***************************************************************************

//
//--------------------------------------------------------------- PRECOMPILED
//

#include "stdafx.h"

//
//--------------------------------------------------- DECLARATION DEPENDENCIES
//

#include "SmartReplace.h"

//
//--------------------------------------------------------------- DECLARATION
//

#include "DialogFolder.h"

//
//--------------------------------------------------- DEFINITION DEPENDENCIES
//

#include "FolderDialog.h"

//
//-------------------------------------------------------------- PREPROCESSOR
//

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

//
//---------------------------------------------------------------- DEFINITION
//

//
//---------------------------------------------------------------------------------------------------
//*************************************     CON/DESTRUCTION     *************************************
//---------------------------------------------------------------------------------------------------
//

//***************************************************************************************************
//**																					  Constructor
//***************************************************************************************************
//**	@DOC		CONSTRUCTION
//**	@MFUNC		Default constructor
//**	@PARM		[in|opt] Pointer to the parent window
//**	@END
//***************************************************************************************************
//inline
CDialogFolder::CDialogFolder( CWnd* pParent /*=NULL*/ )
: CDialog( CDialogFolder::IDD, pParent )
{
	//{{AFX_DATA_INIT(CDialogFolder)
	m_bRecurse = FALSE;
	m_strPath = _T("");
	//}}AFX_DATA_INIT
}

//
//---------------------------------------------------------------------------------------------------
//****************************************     VIRTUALS     *****************************************
//---------------------------------------------------------------------------------------------------
//

//***************************************************************************************************
//**																				   DoDataExchange
//***************************************************************************************************
//**	@DOC		VIRTUALS
//**	@MFUNC		Exchanges data between the dialog's members and its controls
//**	@PARM		[in/out] Pointer to data exchange context
//**	@END
//***************************************************************************************************
//inline
void CDialogFolder::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange( pDX );

	//{{AFX_DATA_MAP(CDialogFolder)
	DDX_Check	( pDX, IDC_CHECK_RECURSE, m_bRecurse );
	DDX_Text	( pDX, IDC_EDIT_PATH	, m_strPath	 );
	//}}AFX_DATA_MAP
}

//
//---------------------------------------------------------------------------------------------------
//****************************************     MESSAGES     *****************************************
//---------------------------------------------------------------------------------------------------
//

BEGIN_MESSAGE_MAP( CDialogFolder, CDialog )
	//{{AFX_MSG_MAP(CDialogFolder)
	ON_BN_CLICKED( IDC_BROWSE, OnBrowse )
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

//***************************************************************************************************
//**																							 OnOK
//***************************************************************************************************
//**	@DOC		MESSAGES
//**	@MFUNC		
//**	@END
//***************************************************************************************************
//inline
void CDialogFolder::OnOK() 
{
	CDialog::OnOK();
}

//***************************************************************************************************
//**																						 OnBrowse
//***************************************************************************************************
//**	@DOC		MESSAGES
//**	@MFUNC		
//**	@END
//***************************************************************************************************
//inline
void CDialogFolder::OnBrowse() 
{
	//
	//	UPDATE MEMBERS FROM CONTROLS
	//
	this->UpdateData( TRUE );

	//
	//	BROWSE FOLDER
	//
	CFolderDialog dlgFolder	( _T( "Select Search Directory" )
							, _T( "Select the place where you want to start your search from the list below:" )
							, this->m_strPath
							);

	if ( IDOK != dlgFolder.DoModal() )
	{
		return;
	}

	//
	//	KEEP FOLDER
	//
	this->m_strPath = dlgFolder.GetPath();

	//
	//	UPDATE MEMBERS TO CONTROLS
	//
	this->UpdateData( FALSE );
}
